package pl.balon.gwt.diagrams.client.images;



import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.IsSerializable;
import com.google.gwt.user.client.ui.Image;

public class ImageFactory implements IsSerializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -3211398189976091605L;
	
	private static ImageFactory instance = null;
	
	public static ImageFactory getInstance(){
		if(instance==null){
			instance= new ImageFactory();
		}
		return instance;
	}
	private ImageFactory() {
		// TODO Auto-generated constructor stub
	}
	
	DiagramsImageBundle iconBundle = (DiagramsImageBundle)GWT.create(DiagramsImageBundle.class);
	
	public void applyTo(Image widget,String imageName  ) {
		if(imageName.compareTo("selectablepoint")==0){
			iconBundle.selectablepoint().applyTo(widget);
		}else if(imageName.compareTo("onmouseoverselectablepoint")==0){
			iconBundle.onmouseoverselectablepoint().applyTo(widget);
		}
	}
	public Image createImage(String imageName){
		
		Image image = null;
		if(imageName.compareTo("selectablepoint")==0){
			image = iconBundle.selectablepoint().createImage();
		}else if(imageName.compareTo("onmouseoverselectablepoint")==0){
			image = iconBundle.onmouseoverselectablepoint().createImage();
		}
		
		return image;
	}

}
